package org.mspring.mlog.web.module.admin;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.mspring.platform.config.ConfigService;
import org.mspring.platform.security.exception.UNLoginException;
import org.mspring.platform.web.freemarker.widget.stereotype.Widget;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author Gao Youbo
 * @since 2013-5-6
 */
@Widget
@RequestMapping("/admin/comment/spam")
public class Admin_SpamWidget extends Admin_CommentWidget {

    @Autowired
    private ConfigService configService;

    @RequestMapping("/config")
    public String config(@RequestParam Map<String, String> configs, HttpServletRequest request, HttpServletResponse response, Model model) {
        configs = configService.getConfigs();
        model.addAllAttributes(configs);
        return "/admin/comment/spam/config";
    }

    @RequestMapping("/config/save")
    public String config_save(@RequestParam Map<String, String> configs, HttpServletRequest request, HttpServletResponse response, Model model) throws UNLoginException {
        configService.setConfigs(configs);
        return prompt(model, "系统消息", "配置保存成功", "/admin/comment/spam/config");
    }
}
